<%@page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@page import="java.util.List"%>
<%@page import="com.yaodian100.ec.coupon.entity.CouponItem"%>
<%@page import="java.text.DateFormat"%>
<%@page import="java.text.SimpleDateFormat"%>
<%@page import="org.apache.commons.lang.StringUtils"%>
<%@page import="com.yaodian100.core.common.utils.DateUtil"%>
<%@page import="org.apache.commons.lang.time.DateUtils"%>
<%@page import="java.util.Date"%>
<%@page import="com.yaodian100.core.common.utils.ServerValue"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<html>
<head>
<link rel="stylesheet" href="/css/jtips.css" type="text/css" id="" media="print, projection, screen" />
<script src="/js/jtip.js"></script>
<script language="javascript">
$().ready(function(){
	
	$("#current_location").html('&nbsp;&gt;&nbsp;我的礼券&nbsp;-&nbsp;目前可用礼券');
	$("#acc_li").attr('class','mb-tab-f');
	$("#use_li").removeAttr('class');
	$("#wait_li").removeAttr('class');
	$("#get_li").removeAttr('class');
	if($("#cTable tr").size()>2){$("#cTable").tablesorter();}
});
</script>
</head>
<body>
	<s:if test="couponRegisterSuccess">
		<DIV id="registerSuccess" title="完成充值" class="dailog-ok-L2" style="display:none" >
		  <p>恭喜您，完成充值！</p> 
		  <div align="center"> <span style="text-align:center;"><a href="#" class="btn-mid" onClick="$(this).parents('div:eq(1)').dialog('close');" >关闭</a></span> </div> 
		</DIV> 
		<script language="javascript">
			$().ready(function(){
				$("#registerSuccess").hide();
				$("#registerSuccess").dialog({
					bgiframe: true,
					height: 155,
					width:300,
					modal: true,
					close: function(event, ui) {
						document.location.reload();
					}
				});
			});
		</script>
	</s:if>
<%
@SuppressWarnings("unchecked")
List<CouponItem> couponList = (List<CouponItem>)request.getAttribute("couponList");
DateFormat dateformat = new SimpleDateFormat("yyyy-MM-dd");
CouponItem couponItem;
%>
      <table id="cTable" class="tablesorter {sortlist: [[0,1]]} tb-2" width="100%" border="0">
      <thead>
        <tr>
          <th width="90"><span><a href="javascript:;">获得日期</a></span></th>
          <th width="105" class="{sorter: 'digit'}"><span><a href="javascript:;">礼券面额</a></span></th>
          <th><span><a href="javascript:;">适用范围</a></span></th>
          <th width="100" class="{sorter: false}">礼券序号</th>
          <th width="80" class="{sorter: 'text'}"><span><a href="javascript:;">生效日</a></span></th>
          <th width="80" class="{sorter: 'text'}"><span><a href="javascript:;">到期日</a></span></th>
        </tr>
      </thead>
      <tbody>
      <%if(couponList.size()==0){ %>
      <tr><td height="30" colspan="5">您没有任何记录。</td></tr>
      <%}else{ %>
      <%for(int i = 0 ; i < couponList.size() ; i++){ 
      	couponItem = couponList.get(i);
      	boolean showWarn = couponItem.getCoupon().getEndDate().getTime()<DateUtils.addDays(new Date(),7).getTime();
      %>
        <tr>
          <td><%=dateformat.format(couponItem.getRegDate())%></td>
          <td><%=couponItem.getCoupon().getFaceValue().setScale(2)%>元</td>
          <td><p><b><% if(StringUtils.isNotBlank(couponItem.getCoupon().getName())){out.write(couponItem.getCoupon().getName());}%></b><br/><%if(StringUtils.isNotBlank(couponItem.getCoupon().getDescription())){ out.write(couponItem.getCoupon().getDescription());} %></p></td>
          <td><%=couponItem.getCode() %></td>
          <td><%=dateformat.format(couponItem.getCoupon().getStartDate())%></td>
          <td><%=showWarn?"<a href=\"javascript:;?width=90&amp;\" name=\"您的礼券将於一周内到期！\" id=\"warn"+couponItem.getCode()+"\" class=\"jTip\">":"" %><p <%=showWarn?" class=\"txt-rd\"":"" %>><%=dateformat.format(couponItem.getCoupon().getEndDate())%></p><%=showWarn?"</a>":"" %></td>
        </tr>
      <%} 
      }%>
      </tbody>  
      </table>
      <!-- 注意事项 -->
      <div class="txt-note">
        <ul>
          <li>．礼券使用明细仅保留 6 个月内的资料。</li>
          <li> ‧使用方式：结帐时系统会显示可使用的礼券清单，请您直接选择要使用的礼券即可。</li>
          <li> ‧礼券一经使用，不予退还。</li>
        </ul>
      </div>
      <!-- 注意事项 -->
</body>
</html>